/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Snake.java
 *
 * Created on 2011.10.29., 16:04:47
 */
package snake;

import java.awt.BorderLayout;
import java.awt.Color;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ButtonGroup;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.JList;

/**
 *
 * @author Ferenczy Máté
 */
public class Snake extends javax.swing.JFrame {
    private Terulet terulet;    //a játéktér ami panelből származik
    private String vNev="Noname";   //a játékkos neve
    private boolean elso=true;       //azt voszgálja hogy most lett-e elindítva a játék
    private File file;          //a mentés helye
    private boolean cancel;
    ArrayList<Elem> highScore=new ArrayList<Elem>();    //a lejobb eredményeket tartalmazó lista
    ButtonGroup bg=new ButtonGroup();   //a beállításokban a választógomb csoportja
    
    /** Creates new form Snake */
    public Snake() throws IOException, ClassNotFoundException {
        initComponents();
        terulet = new Terulet(this);
        terulet.addKeyListener(new java.awt.event.KeyAdapter() {
            @Override
            public void keyPressed(java.awt.event.KeyEvent evt) {
                teruletKeyPressed(evt);
            }
        });
        bpause.setEnabled(false);       //pause button
        bsave.setEnabled(false);        //mentés button
        
        terulet.setBackground(Color.WHITE);
        
        file=new File(System.getProperty("user.dir") + File.separator + "save");
        if(!file.exists()) file.mkdir();
        fcFileChooser.setCurrentDirectory(file);
        
        if (new File(file + File.separator + "HighScore.sav").exists())
        {
            ObjectInputStream ois=new ObjectInputStream(new FileInputStream(file + File.separator + "HighScore.sav"));
            highScore=(ArrayList<Elem>) ois.readObject();
            ois.close();
        }
        
        this.setLocationRelativeTo(null);
        dFileChooser.setLocationRelativeTo(null);
        dChooseName.setLocationRelativeTo(null);
        dChooseName.setModal(true);
        dFileExist.setLocationRelativeTo(null);
        dFileExist.setModal(true);
        dRosszNevHossz.setLocationRelativeTo(null);
        dRosszNevHossz.setModal(true);
        dGameEnd.setLocationRelativeTo(null);
        dGameOver.setLocationRelativeTo(null);
        dHighScore.setLocationRelativeTo(null);
        dBeallit.setLocationRelativeTo(null);
        dBeallit.setModal(true);
        
        bg.add(rbJobbal);
        bg.add(rbFellel);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    
    
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dFileChooser = new javax.swing.JDialog();
        fcFileChooser = new javax.swing.JFileChooser();
        dChooseName = new javax.swing.JDialog();
        bOkChooseName = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        tfChooseName = new javax.swing.JTextField();
        bCancelChooseName = new javax.swing.JButton();
        dFileExist = new javax.swing.JDialog();
        lFileExist1 = new javax.swing.JLabel();
        lFileExist2 = new javax.swing.JLabel();
        bFileExist = new javax.swing.JToggleButton();
        dRosszNevHossz = new javax.swing.JDialog();
        lRosszNevHossz = new javax.swing.JLabel();
        bRosszNevHossz = new javax.swing.JToggleButton();
        dGameOver = new javax.swing.JDialog();
        lGameOver = new javax.swing.JLabel();
        bGameOver = new javax.swing.JButton();
        dGameEnd = new javax.swing.JDialog();
        lGameEnd = new javax.swing.JLabel();
        bGameEnd = new javax.swing.JButton();
        dHighScore = new javax.swing.JDialog();
        spHighScore = new javax.swing.JScrollPane();
        lNevHighScore = new javax.swing.JList();
        lFeliratHighCsore = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        bOkHighScore = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        lPontHighScore = new javax.swing.JList();
        jScrollPane2 = new javax.swing.JScrollPane();
        lIdoHighScore = new javax.swing.JList();
        dBeallit = new javax.swing.JDialog();
        sSeb = new javax.swing.JSlider();
        lBeall = new javax.swing.JLabel();
        rbJobbal = new javax.swing.JRadioButton();
        rbFellel = new javax.swing.JRadioButton();
        jLabel4 = new javax.swing.JLabel();
        bOkBeallit = new javax.swing.JButton();
        lSeb = new javax.swing.JLabel();
        bnewGame = new javax.swing.JButton();
        bload = new javax.swing.JButton();
        bpause = new javax.swing.JButton();
        nev = new javax.swing.JLabel();
        lNev = new javax.swing.JLabel();
        ido = new javax.swing.JLabel();
        lIdo = new javax.swing.JLabel();
        palya = new javax.swing.JLabel();
        lPalya = new javax.swing.JLabel();
        elet = new javax.swing.JLabel();
        lElet = new javax.swing.JLabel();
        lPont = new javax.swing.JLabel();
        pont = new javax.swing.JLabel();
        bsave = new javax.swing.JButton();
        menusor = new javax.swing.JMenuBar();
        menu = new javax.swing.JMenu();
        mnewGame = new javax.swing.JMenuItem();
        mload = new javax.swing.JMenuItem();
        msave = new javax.swing.JMenuItem();
        mHighScore = new javax.swing.JMenuItem();
        mexit = new javax.swing.JMenuItem();
        beall = new javax.swing.JMenu();
        mBeall = new javax.swing.JMenuItem();
        help = new javax.swing.JMenu();
        about = new javax.swing.JMenuItem();

        dFileChooser.setMinimumSize(new java.awt.Dimension(602, 419));
        dFileChooser.setResizable(false);

        fcFileChooser.setFileSelectionMode(javax.swing.JFileChooser.FILES_AND_DIRECTORIES);
        fcFileChooser.setMinimumSize(new java.awt.Dimension(602, 419));

        javax.swing.GroupLayout dFileChooserLayout = new javax.swing.GroupLayout(dFileChooser.getContentPane());
        dFileChooser.getContentPane().setLayout(dFileChooserLayout);
        dFileChooserLayout.setHorizontalGroup(
            dFileChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 592, Short.MAX_VALUE)
            .addGroup(dFileChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(dFileChooserLayout.createSequentialGroup()
                    .addGap(0, 5, Short.MAX_VALUE)
                    .addComponent(fcFileChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 5, Short.MAX_VALUE)))
        );
        dFileChooserLayout.setVerticalGroup(
            dFileChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 397, Short.MAX_VALUE)
            .addGroup(dFileChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(dFileChooserLayout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(fcFileChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );

        dChooseName.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        dChooseName.setTitle("Új játék");
        dChooseName.setMinimumSize(new java.awt.Dimension(240, 200));
        dChooseName.setResizable(false);

        bOkChooseName.setText("OK");
        bOkChooseName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bOkChooseNameActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel1.setText("Kérem adja meg a nevet!");

        tfChooseName.setFont(new java.awt.Font("Tahoma", 0, 12));

        bCancelChooseName.setText("Mégsem");
        bCancelChooseName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bCancelChooseNameActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dChooseNameLayout = new javax.swing.GroupLayout(dChooseName.getContentPane());
        dChooseName.getContentPane().setLayout(dChooseNameLayout);
        dChooseNameLayout.setHorizontalGroup(
            dChooseNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dChooseNameLayout.createSequentialGroup()
                .addGroup(dChooseNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dChooseNameLayout.createSequentialGroup()
                        .addGap(66, 66, 66)
                        .addComponent(tfChooseName, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(dChooseNameLayout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addGroup(dChooseNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addGroup(dChooseNameLayout.createSequentialGroup()
                                .addComponent(bOkChooseName)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 54, Short.MAX_VALUE)
                                .addComponent(bCancelChooseName)))))
                .addContainerGap(34, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        dChooseNameLayout.setVerticalGroup(
            dChooseNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dChooseNameLayout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(tfChooseName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(dChooseNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bOkChooseName)
                    .addComponent(bCancelChooseName))
                .addContainerGap(27, Short.MAX_VALUE))
        );

        dFileExist.setTitle("Fájl létezik");
        dFileExist.setMinimumSize(new java.awt.Dimension(219, 140));
        dFileExist.setResizable(false);

        lFileExist1.setFont(new java.awt.Font("Tahoma", 0, 14));
        lFileExist1.setText("Ilyen név már létezik!");

        lFileExist2.setFont(new java.awt.Font("Tahoma", 0, 14));
        lFileExist2.setText("Kérem adjon meg egy másikat!");

        bFileExist.setText("OK");
        bFileExist.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bFileExistActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dFileExistLayout = new javax.swing.GroupLayout(dFileExist.getContentPane());
        dFileExist.getContentPane().setLayout(dFileExistLayout);
        dFileExistLayout.setHorizontalGroup(
            dFileExistLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, dFileExistLayout.createSequentialGroup()
                .addContainerGap(19, Short.MAX_VALUE)
                .addGroup(dFileExistLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dFileExistLayout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addComponent(lFileExist1))
                    .addComponent(lFileExist2)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, dFileExistLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(bFileExist)
                        .addGap(73, 73, 73)))
                .addContainerGap())
        );
        dFileExistLayout.setVerticalGroup(
            dFileExistLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dFileExistLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(lFileExist1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lFileExist2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(bFileExist)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        dRosszNevHossz.setTitle("Rossz név");
        dRosszNevHossz.setMinimumSize(new java.awt.Dimension(235, 140));
        dRosszNevHossz.setResizable(false);

        lRosszNevHossz.setFont(new java.awt.Font("Tahoma", 0, 14));
        lRosszNevHossz.setText("A név hossza 1 és 7 között lehet!");

        bRosszNevHossz.setText("OK");
        bRosszNevHossz.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bRosszNevHosszActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dRosszNevHosszLayout = new javax.swing.GroupLayout(dRosszNevHossz.getContentPane());
        dRosszNevHossz.getContentPane().setLayout(dRosszNevHosszLayout);
        dRosszNevHosszLayout.setHorizontalGroup(
            dRosszNevHosszLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dRosszNevHosszLayout.createSequentialGroup()
                .addGroup(dRosszNevHosszLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dRosszNevHosszLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(lRosszNevHossz))
                    .addGroup(dRosszNevHosszLayout.createSequentialGroup()
                        .addGap(83, 83, 83)
                        .addComponent(bRosszNevHossz)))
                .addContainerGap(24, Short.MAX_VALUE))
        );
        dRosszNevHosszLayout.setVerticalGroup(
            dRosszNevHosszLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dRosszNevHosszLayout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(lRosszNevHossz)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(bRosszNevHossz)
                .addContainerGap(55, Short.MAX_VALUE))
        );

        dGameOver.setTitle("Vége a játéknak");
        dGameOver.setMinimumSize(new java.awt.Dimension(275, 132));

        lGameOver.setFont(new java.awt.Font("Tahoma", 0, 14));
        lGameOver.setText("Elfogyott az életed! Vége a játéknak!");

        bGameOver.setText("OK");
        bGameOver.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bGameOverActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dGameOverLayout = new javax.swing.GroupLayout(dGameOver.getContentPane());
        dGameOver.getContentPane().setLayout(dGameOverLayout);
        dGameOverLayout.setHorizontalGroup(
            dGameOverLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dGameOverLayout.createSequentialGroup()
                .addGroup(dGameOverLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dGameOverLayout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addComponent(lGameOver))
                    .addGroup(dGameOverLayout.createSequentialGroup()
                        .addGap(111, 111, 111)
                        .addComponent(bGameOver)))
                .addContainerGap(25, Short.MAX_VALUE))
        );
        dGameOverLayout.setVerticalGroup(
            dGameOverLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dGameOverLayout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(lGameOver)
                .addGap(18, 18, 18)
                .addComponent(bGameOver)
                .addContainerGap(27, Short.MAX_VALUE))
        );

        dGameEnd.setTitle("Gratulálok!");
        dGameEnd.setMinimumSize(new java.awt.Dimension(259, 158));

        lGameEnd.setFont(new java.awt.Font("Tahoma", 0, 14));
        lGameEnd.setText("Gratulálok! Végeztél a játékkal!");

        bGameEnd.setText("OK");
        bGameEnd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bGameEndActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dGameEndLayout = new javax.swing.GroupLayout(dGameEnd.getContentPane());
        dGameEnd.getContentPane().setLayout(dGameEndLayout);
        dGameEndLayout.setHorizontalGroup(
            dGameEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dGameEndLayout.createSequentialGroup()
                .addGroup(dGameEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dGameEndLayout.createSequentialGroup()
                        .addGap(40, 40, 40)
                        .addComponent(lGameEnd))
                    .addGroup(dGameEndLayout.createSequentialGroup()
                        .addGap(101, 101, 101)
                        .addComponent(bGameEnd)))
                .addContainerGap(35, Short.MAX_VALUE))
        );
        dGameEndLayout.setVerticalGroup(
            dGameEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dGameEndLayout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(lGameEnd)
                .addGap(30, 30, 30)
                .addComponent(bGameEnd)
                .addContainerGap(30, Short.MAX_VALUE))
        );

        dHighScore.setTitle("Top");
        dHighScore.setMinimumSize(new java.awt.Dimension(321, 416));

        spHighScore.setViewportView(lNevHighScore);

        lFeliratHighCsore.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lFeliratHighCsore.setText("Név                       Pont              Idő");

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel2.setText("Legjobb eredmények");

        bOkHighScore.setText("OK");
        bOkHighScore.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bOkHighScoreActionPerformed(evt);
            }
        });

        jScrollPane1.setViewportView(lPontHighScore);

        jScrollPane2.setViewportView(lIdoHighScore);

        javax.swing.GroupLayout dHighScoreLayout = new javax.swing.GroupLayout(dHighScore.getContentPane());
        dHighScore.getContentPane().setLayout(dHighScoreLayout);
        dHighScoreLayout.setHorizontalGroup(
            dHighScoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dHighScoreLayout.createSequentialGroup()
                .addGroup(dHighScoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dHighScoreLayout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(dHighScoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lFeliratHighCsore)
                            .addGroup(dHighScoreLayout.createSequentialGroup()
                                .addComponent(spHighScore, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addGroup(dHighScoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(bOkHighScore)
                                    .addGroup(dHighScoreLayout.createSequentialGroup()
                                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                    .addGroup(dHighScoreLayout.createSequentialGroup()
                        .addGap(93, 93, 93)
                        .addComponent(jLabel2)))
                .addContainerGap(33, Short.MAX_VALUE))
        );
        dHighScoreLayout.setVerticalGroup(
            dHighScoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dHighScoreLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addGap(23, 23, 23)
                .addComponent(lFeliratHighCsore)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(dHighScoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE)
                    .addComponent(spHighScore, javax.swing.GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(bOkHighScore)
                .addContainerGap())
        );

        dBeallit.setMinimumSize(new java.awt.Dimension(350, 222));

        sSeb.setValue(67);
        sSeb.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                sSebMouseReleased(evt);
            }
        });

        lBeall.setFont(new java.awt.Font("Tahoma", 0, 14));
        lBeall.setText("Beállítások");

        rbJobbal.setSelected(true);
        rbJobbal.setText("jobbra, balra");

        rbFellel.setText("jobbra, fel, balra, le");

        jLabel4.setText("Sebesség");

        bOkBeallit.setText("OK");
        bOkBeallit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bOkBeallitActionPerformed(evt);
            }
        });

        lSeb.setText("67");

        javax.swing.GroupLayout dBeallitLayout = new javax.swing.GroupLayout(dBeallit.getContentPane());
        dBeallit.getContentPane().setLayout(dBeallitLayout);
        dBeallitLayout.setHorizontalGroup(
            dBeallitLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dBeallitLayout.createSequentialGroup()
                .addGroup(dBeallitLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dBeallitLayout.createSequentialGroup()
                        .addGap(135, 135, 135)
                        .addComponent(lBeall))
                    .addGroup(dBeallitLayout.createSequentialGroup()
                        .addGap(45, 45, 45)
                        .addGroup(dBeallitLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(rbFellel)
                            .addComponent(rbJobbal)
                            .addGroup(dBeallitLayout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addGap(18, 18, 18)
                                .addGroup(dBeallitLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(dBeallitLayout.createSequentialGroup()
                                        .addGap(10, 10, 10)
                                        .addComponent(bOkBeallit))
                                    .addGroup(dBeallitLayout.createSequentialGroup()
                                        .addComponent(sSeb, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(lSeb)))))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        dBeallitLayout.setVerticalGroup(
            dBeallitLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dBeallitLayout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(lBeall)
                .addGap(18, 18, 18)
                .addComponent(rbJobbal)
                .addGap(4, 4, 4)
                .addComponent(rbFellel)
                .addGap(18, 18, 18)
                .addGroup(dBeallitLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lSeb)
                    .addGroup(dBeallitLayout.createSequentialGroup()
                        .addGroup(dBeallitLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(sSeb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(bOkBeallit)))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Snake");
        setMinimumSize(new java.awt.Dimension(400, 290));
        setResizable(false);

        bnewGame.setText("Új játék");
        bnewGame.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bnewGameActionPerformed(evt);
            }
        });

        bload.setText("Betöltés");
        bload.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bloadActionPerformed(evt);
            }
        });

        bpause.setText("Szünet");
        bpause.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bpauseActionPerformed(evt);
            }
        });

        nev.setFont(new java.awt.Font("Tahoma", 0, 12));
        nev.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        nev.setText("Név");

        lNev.setFont(new java.awt.Font("Tahoma", 0, 12));
        lNev.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lNev.setText("noname");

        ido.setFont(new java.awt.Font("Tahoma", 0, 12));
        ido.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        ido.setText("Idő");

        lIdo.setFont(new java.awt.Font("Tahoma", 0, 12));
        lIdo.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lIdo.setText("0:00");

        palya.setFont(new java.awt.Font("Tahoma", 0, 12));
        palya.setText("Pálya");

        lPalya.setFont(new java.awt.Font("Tahoma", 0, 12));
        lPalya.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lPalya.setText("0");

        elet.setFont(new java.awt.Font("Tahoma", 0, 12));
        elet.setText("Élet");

        lElet.setFont(new java.awt.Font("Tahoma", 0, 12));
        lElet.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lElet.setText("0");

        lPont.setBackground(new java.awt.Color(255, 255, 255));
        lPont.setFont(new java.awt.Font("Tahoma", 0, 12));
        lPont.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lPont.setText("0");

        pont.setFont(new java.awt.Font("Tahoma", 0, 12));
        pont.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        pont.setText("Pont");

        bsave.setText("Mentés");
        bsave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bsaveActionPerformed(evt);
            }
        });

        menu.setText("Menü");

        mnewGame.setText("Új játék");
        mnewGame.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnewGameActionPerformed(evt);
            }
        });
        menu.add(mnewGame);

        mload.setText("Betöltés");
        mload.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mloadActionPerformed(evt);
            }
        });
        menu.add(mload);

        msave.setText("Mentés");
        msave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                msaveActionPerformed(evt);
            }
        });
        menu.add(msave);

        mHighScore.setText("Legjobb eredmények");
        mHighScore.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mHighScoreActionPerformed(evt);
            }
        });
        menu.add(mHighScore);

        mexit.setText("Kilépés");
        mexit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mexitActionPerformed(evt);
            }
        });
        menu.add(mexit);

        menusor.add(menu);

        beall.setText("Beállítások");

        mBeall.setText("Beállítások");
        mBeall.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mBeallActionPerformed(evt);
            }
        });
        beall.add(mBeall);

        menusor.add(beall);

        help.setText("Segítség");

        about.setText("Játékleírás");
        about.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aboutActionPerformed(evt);
            }
        });
        help.add(about);

        menusor.add(help);

        setJMenuBar(menusor);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(319, 319, 319)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(ido, javax.swing.GroupLayout.DEFAULT_SIZE, 21, Short.MAX_VALUE)
                        .addGap(25, 25, 25)
                        .addComponent(lIdo))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(palya)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
                        .addComponent(lPalya, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(nev)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lNev))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(elet)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 25, Short.MAX_VALUE)
                        .addComponent(lElet, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(pont)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lPont, javax.swing.GroupLayout.DEFAULT_SIZE, 39, Short.MAX_VALUE))
                    .addComponent(bload, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(bsave, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE)
                    .addComponent(bpause, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE)
                    .addComponent(bnewGame, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(12, 12, 12)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nev)
                    .addComponent(lNev))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lIdo)
                    .addComponent(ido))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(palya)
                    .addComponent(lPalya))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(elet)
                    .addComponent(lElet))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pont)
                    .addComponent(lPont, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(bnewGame)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(bload)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bsave)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bpause)
                .addContainerGap(12, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


public void gameOver()
{
    terulet.setPause(true);
    dGameOver.setVisible(true);
}

public void gameEnd(long p, long mp, int pont) throws IOException
{
    terulet.setPause(true);
    highScore.add(new Elem(vNev, p, mp, pont));
    Collections.sort(highScore);
    if (highScore.size()==21) highScore.remove(20);
    
    ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(file + File.separator + "HighScore.sav"));
    oos.writeObject(highScore);
    oos.close();
    
    dGameEnd.setVisible(true);
}
    
public void setlIdo(long p, long mp)
{
    if (mp<10) lIdo.setText(p+":0"+mp);
    else lIdo.setText(p+":"+mp);
}

public void setlPalya(int pa)
{
    lPalya.setText(""+pa);
}

public void setlElet(int el)
{
    lElet.setText(""+el);
}

public void setlPont(int po)
{
    lPont.setText(""+po);
}
    
public String getlPont()
{
    return lPont.getText();
}

public void setbpauseText(String szoveg)
{
    bpause.setText(szoveg);
}

//uj: azt vizsgálja hogy új játék-e vagy betöltés, és attól függ hogy melyik függvényt hívja meg
private void indul(boolean uj)
{
    cancel=false;
    if (uj)
    {
        //új játék
        boolean jatkezd;
        do
        {
            jatkezd=false;
            dChooseName.setVisible(true);
            if (new File(file+File.separator+vNev+".sav").exists() && !cancel)
            {
                dFileExist.setVisible(true);
                jatkezd=true;
            }
            if ((vNev.length()<1 || vNev.length()>7) && !cancel)
            {
                dRosszNevHossz.setVisible(true);
                jatkezd=true;
            }
        } while(jatkezd && !cancel);
        if (!cancel)
        {
            file=new File(System.getProperty("user.dir")+File.separator+"save");
            terulet.ujJatek();
            terulet.setPause(false);
        }
    }
    else
    {
        //betöltés
        int gomb=fcFileChooser.showOpenDialog(dFileChooser);
        if (gomb==JFileChooser.APPROVE_OPTION)
        {
            if(fcFileChooser.getSelectedFile().getAbsolutePath().endsWith(".sav"))
            {
                String ut=fcFileChooser.getSelectedFile().getPath().split("\\\\")[0];
                for(int i=1; i<fcFileChooser.getSelectedFile().getPath().split("\\\\").length-1; i++)
                    ut=ut+File.separator+fcFileChooser.getSelectedFile().getPath().split("\\\\")[i];
                vNev=fcFileChooser.getSelectedFile().getPath().split("\\\\")[(fcFileChooser.getSelectedFile().getPath().split("\\\\").length)-1].substring(0, fcFileChooser.getSelectedFile().getPath().split("\\\\")[(fcFileChooser.getSelectedFile().getPath().split("\\\\").length)-1].length()-4);
                file=new File(ut);
                lNev.setText(vNev);
                try {
                    terulet.betolt(new File(file+File.separator+vNev+".sav"));
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(Snake.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IOException ex) {
                    Logger.getLogger(Snake.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            else cancel=true;
        }
        else if(gomb==JFileChooser.CANCEL_OPTION)
        {
            cancel=true;
        }
    }
    if (!cancel)
    {
        elso=false;
        bpause.setEnabled(true);
        bsave.setEnabled(true);
        add(terulet, BorderLayout.WEST);    //játéktér hozzáadása
        pack();
        lNev.setText(vNev);
        terulet.requestFocus();     //játéktér fókuszba állítása a gombok érzékeléséhez
        terulet.repaint();
    }
}

private void mexitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mexitActionPerformed
    System.exit(0);
}//GEN-LAST:event_mexitActionPerformed

private void bnewGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnewGameActionPerformed
    if (elso) 
    {
        indul(true);
    }
    else 
    {
        terulet.ujJatek();
        terulet.requestFocus();
        terulet.repaint();
    }
}//GEN-LAST:event_bnewGameActionPerformed

private void bloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bloadActionPerformed
    if (elso)
    {
        indul(false);
    }
    else
    {
        try {
            terulet.betolt(new File(file+File.separator+vNev+".sav"));
        } catch (IOException ex) {
            Logger.getLogger(Snake.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Snake.class.getName()).log(Level.SEVERE, null, ex);
        }
        terulet.requestFocus();
        terulet.repaint();
    }
}//GEN-LAST:event_bloadActionPerformed

private void bpauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bpauseActionPerformed
    if(bpause.getText().equals("Szünet"))
    {
        bpause.setText("Tovább");
        terulet.setPause(true);
    } else
    {
        bpause.setText("Szünet");
        terulet.setPause(false);
    }
    terulet.requestFocus();
    terulet.repaint();
}//GEN-LAST:event_bpauseActionPerformed

private void mnewGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnewGameActionPerformed
    terulet.setPause(true);
    indul(true);
}//GEN-LAST:event_mnewGameActionPerformed

private void mloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mloadActionPerformed
    indul(false);
}//GEN-LAST:event_mloadActionPerformed

private void msaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_msaveActionPerformed
    try {
        terulet.mentes(new File(file+File.separator+vNev+".sav"));
    } catch (IOException ex) {
        Logger.getLogger(Snake.class.getName()).log(Level.SEVERE, null, ex);
    }
    terulet.requestFocus();
    terulet.repaint();
}//GEN-LAST:event_msaveActionPerformed

private void bOkChooseNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bOkChooseNameActionPerformed
    vNev=tfChooseName.getText();
    lNev.setText(vNev);
    dChooseName.setVisible(false);
}//GEN-LAST:event_bOkChooseNameActionPerformed

private void bFileExistActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bFileExistActionPerformed
    dFileExist.setVisible(false);
}//GEN-LAST:event_bFileExistActionPerformed

private void bRosszNevHosszActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bRosszNevHosszActionPerformed
    dRosszNevHossz.setVisible(false);
}//GEN-LAST:event_bRosszNevHosszActionPerformed

private void bsaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bsaveActionPerformed
    try {
        terulet.mentes(new File(file+File.separator+vNev+".sav"));
    } catch (IOException ex) {
        Logger.getLogger(Snake.class.getName()).log(Level.SEVERE, null, ex);
    }
    terulet.requestFocus();
    terulet.repaint();
}//GEN-LAST:event_bsaveActionPerformed

private void bCancelChooseNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bCancelChooseNameActionPerformed
    cancel=true;
    dChooseName.setVisible(false);
}//GEN-LAST:event_bCancelChooseNameActionPerformed

private void bGameEndActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bGameEndActionPerformed
    dGameEnd.setVisible(false);
}//GEN-LAST:event_bGameEndActionPerformed

private void bGameOverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bGameOverActionPerformed
    dGameOver.setVisible(false);
}//GEN-LAST:event_bGameOverActionPerformed

private void bOkHighScoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bOkHighScoreActionPerformed
    dHighScore.setVisible(false);
}//GEN-LAST:event_bOkHighScoreActionPerformed

private void mHighScoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mHighScoreActionPerformed
    DefaultListModel mNev=new DefaultListModel();
    DefaultListModel mPont=new DefaultListModel();
    DefaultListModel mIdo=new DefaultListModel();
    for (int i=0; i<highScore.size(); i++)
    {
        mNev.addElement((i+1)+". "+highScore.get(i).getNev());
        mPont.addElement(highScore.get(i).getPont());
        mIdo.addElement(highScore.get(i).getIdo()/60+":"+highScore.get(i).getIdo()%60);
    }
    lNevHighScore.setModel(mNev);
    lPontHighScore.setModel(mPont);
    lIdoHighScore.setModel(mIdo);
    dHighScore.setVisible(true);
}//GEN-LAST:event_mHighScoreActionPerformed

private void aboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutActionPerformed
    File elut=new File("Help.pdf");
    Process p;
        try {
            p=Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+elut.getAbsolutePath());
            p.waitFor();
        } catch (Exception ex) {
            Logger.getLogger(Snake.class.getName()).log(Level.SEVERE, null, ex);
        }

}//GEN-LAST:event_aboutActionPerformed

private void mBeallActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mBeallActionPerformed
    dBeallit.setVisible(true);
}//GEN-LAST:event_mBeallActionPerformed

private void bOkBeallitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bOkBeallitActionPerformed
    dBeallit.setVisible(false);
    double seb= (double) sSeb.getValue();
    seb=1-(seb/100);
    terulet.setSeb((int) (seb*225+25));
    terulet.setJobbal(rbJobbal.isSelected());
}//GEN-LAST:event_bOkBeallitActionPerformed

private void sSebMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sSebMouseReleased
    lSeb.setText(""+sSeb.getValue());
}//GEN-LAST:event_sSebMouseReleased

private void teruletKeyPressed(java.awt.event.KeyEvent evt) {
    terulet.mozg(evt.getKeyCode());
}

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Snake.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Snake.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Snake.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Snake.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    new Snake().setVisible(true);
                } catch (IOException ex) {
                    Logger.getLogger(Snake.class.getName()).log(Level.SEVERE, null, ex);
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(Snake.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem about;
    private javax.swing.JButton bCancelChooseName;
    private javax.swing.JToggleButton bFileExist;
    private javax.swing.JButton bGameEnd;
    private javax.swing.JButton bGameOver;
    private javax.swing.JButton bOkBeallit;
    private javax.swing.JButton bOkChooseName;
    private javax.swing.JButton bOkHighScore;
    private javax.swing.JToggleButton bRosszNevHossz;
    private javax.swing.JMenu beall;
    private javax.swing.JButton bload;
    private javax.swing.JButton bnewGame;
    private javax.swing.JButton bpause;
    private javax.swing.JButton bsave;
    private javax.swing.JDialog dBeallit;
    private javax.swing.JDialog dChooseName;
    private javax.swing.JDialog dFileChooser;
    private javax.swing.JDialog dFileExist;
    private javax.swing.JDialog dGameEnd;
    private javax.swing.JDialog dGameOver;
    private javax.swing.JDialog dHighScore;
    private javax.swing.JDialog dRosszNevHossz;
    private javax.swing.JLabel elet;
    private javax.swing.JFileChooser fcFileChooser;
    private javax.swing.JMenu help;
    private javax.swing.JLabel ido;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lBeall;
    private javax.swing.JLabel lElet;
    private javax.swing.JLabel lFeliratHighCsore;
    private javax.swing.JLabel lFileExist1;
    private javax.swing.JLabel lFileExist2;
    private javax.swing.JLabel lGameEnd;
    private javax.swing.JLabel lGameOver;
    private javax.swing.JLabel lIdo;
    private javax.swing.JList lIdoHighScore;
    private javax.swing.JLabel lNev;
    private javax.swing.JList lNevHighScore;
    private javax.swing.JLabel lPalya;
    private javax.swing.JLabel lPont;
    private javax.swing.JList lPontHighScore;
    private javax.swing.JLabel lRosszNevHossz;
    private javax.swing.JLabel lSeb;
    private javax.swing.JMenuItem mBeall;
    private javax.swing.JMenuItem mHighScore;
    private javax.swing.JMenu menu;
    private javax.swing.JMenuBar menusor;
    private javax.swing.JMenuItem mexit;
    private javax.swing.JMenuItem mload;
    private javax.swing.JMenuItem mnewGame;
    private javax.swing.JMenuItem msave;
    private javax.swing.JLabel nev;
    private javax.swing.JLabel palya;
    private javax.swing.JLabel pont;
    private javax.swing.JRadioButton rbFellel;
    private javax.swing.JRadioButton rbJobbal;
    private javax.swing.JSlider sSeb;
    private javax.swing.JScrollPane spHighScore;
    private javax.swing.JTextField tfChooseName;
    // End of variables declaration//GEN-END:variables
}